<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/common/taglib.jsp"%>
<%@ include file="/WEB-INF/common/header.jsp"%>

	<div class="layui-fluid">

		<form class="layui-form" isLoad="${empty bean ? 0 : 1}">
		  
		  <div class="layui-form-item">
		    <label class="layui-form-label">排序：</label>
		    <div class="layui-input-block">
		   		<input type="text" name="sort" required lay-verType="tips" lay-verify="number" placeholder="数字" autocomplete="off" class="layui-input" style="width:50px;" value="${empty bean ? 1: bean.sort}" />
		    </div>
		  </div>
		  
		  <hr>
			
		  <div class="layui-form-item">
		    <label class="layui-form-label">AppID：</label>
		    <div class="layui-input-block">
		    	<c:choose>
		    		<c:when test="${not empty bean && bean.appid != null && bean.appid != '' }">
		    			<div class="layui-form-mid layui-word-aux">${bean.appid }</div>
		      			<input type="hidden" name="appid" />
		    		</c:when>
		    		<c:otherwise>
		    			<input type="text" name="appid" required="" lay-verType="tips" lay-verify="required" placeholder="请输入开发者AppID" autocomplete="off" class="layui-input" maxlength="18" style="width:200px;" />
		    		</c:otherwise>
		    	</c:choose>
		    </div>
		  </div>
		  
		  <hr>
		  
		  <div class="layui-form-item layui-form-text">
		    <label class="layui-form-label">Secret：</label>
		    <div class="layui-input-inline">
		    	<c:choose>
		    		<c:when test="${not empty bean && bean.secret != null && bean.secret != '' }">
		    			<div class="layui-form-mid layui-word-aux">${bean.secret }</div>
		      			<input type="hidden" name="secret" />
		    		</c:when>
		    		<c:otherwise>
		    			<input type="text" name="secret" required lay-verType="tips" lay-verify="required" placeholder="请输入开发者Secret" autocomplete="off" class="layui-input" maxlength="32" style="width:350px;" />
		    		</c:otherwise>
		    	</c:choose>
		    </div>
		  </div>
		  
		  <hr>
		  
		  <div class="layui-form-item layui-form-text">
		    <label class="layui-form-label">Token：</label>
		    <div class="layui-input-inline">
		    	<input type="text" id="token" name="token" required lay-verType="tips" lay-verify="required" placeholder="请输入3-32字符的自定义Token" autocomplete="off" class="layui-input" maxlength="32" style="width:350px;" />
		    </div>
		    <div class="layui-input-inline">
				<button type="button" class="layui-btn" onclick="randomToken()">随机生成</button>
		    </div>
		  </div>
		  
		  <hr>
		  
		  <div class="layui-form-item">
		    <label class="layui-form-label">类型：</label>
		    <div class="layui-input-inline">
		      <select name="type" lay-verify="required" lay-verType="tips" class="fsSelect fsDict" isLoad="1" dict="type" addNull="1"></select>
		    </div>
		    
		    <label class="layui-form-label">状态：</label>
		    <div class="layui-input-inline">
		      <!-- <select name="status" class="fsSelect" isLoad="1" dict="status" addNull="1"></select> -->
		      <c:choose>
		    		<c:when test="${not empty bean }">
		    			<input type="checkbox" name="status" lay-skin="switch" lay-text="启用|禁用" value="0" {{bean.status == 0 'checked' : ''}} />
		    		</c:when>
		    		<c:otherwise>
		    			<input type="checkbox" name="status" lay-skin="switch" lay-text="启用|禁用" value="0" checked />
		    		</c:otherwise>
		    	</c:choose>
		      
		    </div>
		  </div>
		  
		  <hr>
		  
		  <div class="layui-form-item">
		    <label class="layui-form-label">描述：</label>
		    <div class="layui-input-block">
		      <textarea name="notice" placeholder="请输入微信配置描述" class="layui-textarea" style="width:400px;"></textarea>
		    </div>
		  </div>
		  
		  <hr/>
		  
		  <div class="layui-form-item" style="text-align: center;">
		  	 <button class="layui-btn" lay-submit="" lay-filter="${empty bean ? 'save' : 'edit' }" url="${ctx }/wx/conf/add?add=${empty bean ? true : false }"><i class="layui-icon">&#xe642;</i>${empty bean ? '新增' : '编辑' }</button>
	     	 <button type="button" class="layui-btn layui-btn-primary" function="close">关闭</button>
	   	  </div>
	  
		</form>
	</div>
	
	<script type="text/javascript">
		function randomToken(){
			var randomToken = randomUUID(32);
			$("#token").val(randomToken)
		}
		
		function randomUUID(n) {
			var chars = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'];
			var res = "";
			for (var i = 0; i < n; i++) {
			  var id = Math.ceil(Math.random() * 59);
			  res += chars[id];
			}
			return res;
		}
	</script>

	<%@ include file="/WEB-INF/common/bottom.jsp"%>